package com.zt.controller;

import com.zt.config.MsgHandlerContext;
import com.zt.config.MsgType;
import com.zt.strategy.MsgHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * web
 *
 * @author zt
 * @date 2021/12/10 17:20
 */
@RestController
@RequestMapping("/task")
public class TaskController {
    @Autowired
    private MsgHandlerContext msgHandlerContext;

    @GetMapping("msg")
    public void handleMsg(String msg) {
        MsgType msgType = MsgType.valueOf(msg);
        MsgHandler handler = msgHandlerContext.getMsgHandler(msgType);
        handler.handle("我是具体的一条信息，hello world！");
    }

}
